package com.lagou.mapper.impl;

import com.lagou.mapper.IShopUserDao;
import com.lagou.pojo.ShopUser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @author ADMIN
 * @date 2021/3/26 22:54
 */
public class IShopUserDaoImpl implements IShopUserDao {
    @Override
    public List<ShopUser> findAll() throws IOException {
        InputStream resourceAsStream =
                Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new
                SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        List<ShopUser> userList = sqlSession.selectList("com.lagou.mapper.ShopUserMapper.findAll");
        sqlSession.close();
        return userList;
    }
}
